package com.gitee.wsl.math.random

import kotlin.random.Random


fun <T> List<T>.random(random: Random = Random): T {
    if (this.isEmpty()) throw IllegalArgumentException("Empty list")
    return this[random.nextInt(this.size)]
}

operator fun <T> Random.get(list: List<T>): T = list.random(this)


/*
operator fun <T : Interpolable<T>> Random.get(l: T, r: T): T = (this.nextDoubleInclusive()).toRatio().interpolate(l, r)

operator fun Random.get(rectangle: Rectangle): Point = Point(this[rectangle.left, rectangle.right], this[rectangle.top, rectangle.bottom])
fun <T : MutableInterpolable<T>> T.setToRandom(min: T, max: T, random: Random = Random) { this.setToInterpolated(random.nextDouble().toRatio(), min, max) }
*/
